package com.asiainfo.wx.api.apibase.exception;

import com.asiainfo.wx.api.apibase.constants.WxResultEnum;

/**
 * Copyright: Copyright (c) 2019  zteits
 *
 * @ClassName: com.asiainfo.wx.api.apibase.exception
 * @Description:应用异常
 * @version: v1.0.0
 * @author: atao
 * @date: 2019-10-29   17:27
 * Modification History:
 * Date         Author          Version      Description
 * ---------------------------------------------------------*
 * 2019-10-29      atao          v1.0.0          创建
 */
public class AppException extends RuntimeException {

    protected WxResultEnum wxResultEnum = WxResultEnum.APP_FAIL;

    private String msg;

    public AppException() {
        this.msg = wxResultEnum.getDefaultMsg();
    }

    public AppException(String errMsg) {
        if (errMsg == null || errMsg.length() == 0) {
            errMsg = wxResultEnum.getDefaultMsg();
        }
        this.msg = errMsg;
    }

    public AppException(Throwable e) {
        super(e);
        this.msg = wxResultEnum.getDefaultMsg();
    }

    public AppException(String errMsg, Throwable e) {
        super(e);
        if (errMsg == null || errMsg.length() == 0) {
            errMsg = wxResultEnum.getDefaultMsg();
        }
        this.msg = errMsg;
    }

    @Override
    public String getMessage() {
        return this.msg;
    }

    public WxResultEnum getWxResultEnum() {
        return wxResultEnum;
    }

}
